<template>
	<view class="bg-container">
			<view class="product-item" v-for="(item,index) in goodsList" :key="index">
				<view class="product-row">
					<view class="product-pic">
						<img class="shop-img" :src="'http://cdn.ewayz.cn:15001/UploadFiles//Store_Files/store/2/Product/show/thumb350_350/'+item.ShowImg"/>
					</view>
					<view class="product-info">
						<view class="product-title">{{item.Name}}</view>
						<view class="amount">￥{{item.ShopPrice}}</view>
						<view class="product-amount">一级佣金 <text class="red">￥{{item.Price1}}</text> 二级佣金<text class="red">￥{{item.Price2}}</text></view>
					</view>
				</view>
				<view class="share-row">
					<view class="button share-button" @tap="sharePoster(item)">分享海报</view>
					
				</view>
			</view>		
			
	</view>
</template>

<script>
	export default{
		data(){
			return {
				goodsList:[],
				userInfo:{}
			}
		},
		onLoad() {
			this.userInfo=JSON.parse(uni.getStorageSync("userInfo")==''?null:uni.getStorageSync("userInfo"));
		
			this.getGoodsList(0);
		},
		methods:{
			getGoodsList(trait) {
				let that = this;
				uni.request({
				    url: this.$config.API_Gateway,
					method:"POST",
					data:{
						"method": "API.Store.Categories.StoreTraitProduct.List",
						"ver": "1.0",
						"timestamp": parseInt(Date.parse(new Date()) / 1000 + 8 * 60 * 60).toString(),
						"format": "",
						"access_token": "",
						"session_token": "",
						"storeid": that.userInfo.StoreUserInfo.StoreId,
						"trait": trait,
						"count": 999,
						"storecid": 0
					},
					success: (res) => {
						this.goodsList=res.data.Items;
						console.log(this.goodsList);
				    }
				});
				
			},
			jump(path, parmas) {
				this.$Router.push({
					path: path,
					query: parmas
				});
			},
			sharePoster(item){
				// #/pages/public/poster/index?id=1250&image=http%3A%2F%2Fcdn.ewayz.cn%3A15001%2FUploadFiles%2F%2FStore_Files%2Fstore%2F2%2FProduct%2Fshow%2Fthumb350_350%2Fps_2012160607225240685.png&title=1250&price=128&original_price=128&teamNum=0&posterType=goods
				
				console.log(item);
				this.$Router.push({
					path: "/pages/public/poster/index",
					query: {
						id:item.Pid,
						posterType:"goods"
					}
				});
				
			}
		}
	}
</script>

<style scope="scoped" lang="scss">
	.bg-container{
		width:100%;
		height:100%;
		background-color:white;
		display:flex;
		flex-direction:column;
		align-items:center;
		justify-content:flex-start;
		
	}
	
		.product-item{
			width:100%;
			padding:30rpx 40rpx;
			
			
			.shop-img {
				width: 180rpx;
				height: 180rpx;
				border-radius: 6upx;
				margin-right: 30upx;
				background: #ccc;
			}
			
			.product-row{
				font-size:32rpx;
				font-weight:bold;
				display:inline-flex;
				
				
				.product-pic{
					width:180rpx;
					height:180rpx;
					background-color:#efefef;
					margin-right:40rpx;
					flex-shrink:0;
					flex-grow:0;
				}
				
				.product-info{
					.product-title{
						height:80rpx;
						line-height:40rpx;
						overflow:hidden;
						font-size:32rpx;
					}	
					.amount{
						font-size:30rpx;
						line-height:60rpx;
						color:#ee1919;
					}
					.product-amount{
						line-height:40rpx;
						font-size:24rpx;
						.red{
							color:#ee1919;
							margin-right:20rpx;
						}
					}
				}
				
				
				
				
				.level{
					float:Right;
					font-size:28rpx;
					color:rgb(240,199,135);
				}
			}
			.record-subtitle{
				color:#888888;
				font-size:28rpx;
				margin-top:15rpx;
			}
			
			
			.share-row{
				text-align:right;
				margin-top:20rpx;
				padding-top:20rpx;
				border-top:solid 1px #efefef;
				font-size:28rpx;
				
				.button{
					padding:6rpx 10rpx;
					border:solid 1px #888888;
					display:inline-block;
					
				}
			}
		}
</style>
